<?php
	header("Content-type:text/html;charset=utf-8");
	define('HOST','127.0.0.1');
	define('USER','root');
	define('PWD','root');
	define('DB','news');
	$link = mysqli_connect(HOST,USER,PWD,DB) or die(mysqli_connect_error());
	mysqli_select_db($link,DB) or die(mysqli_error($link));
	mysqli_set_charset($link,'utf8') or die(mysqli_error($link));
	$sql = "select * from news_list ";
	$result = mysqli_query($link,$sql);

	$data = array();
	while ($row = mysqli_fetch_assoc($result)) {
		$data[]=$row;
	}

	mysqli_close($link);
	mysqli_free_result($result);
?>
<!DOCTYPE html>
<html>
<head>
	<title>news_list</title>
	<meta charset="utf-8">
</head>
<body>
	<table width="600px" border=1 align="center" cellspacing="0">
		<tr>
			<th>id</th>
			<th>新闻标题</th>
			<th>新闻内容</th>
			<th>新闻图片</th>
			<th>新闻作者</th>
			<th>新闻日期</th>
		</tr>
		<?php foreach ($data as $val): ?>
		<tr>
			<td><?php echo $val['news_id']; ?></td>
			<td><?php echo $val['news_title']; ?></td>
			<td><?php echo $val['news_content']; ?></td>
			<td><?php echo $val['news_photo']; ?></td>
			<td><?php echo $val['news_author']; ?></td>
			<td><?php echo $val['news_date']; ?></td>
		</tr>
		<?php endforeach; ?>
	</table>
</body>
</html>